package com.java.multipledatasource.spring.service;

import com.java.multipledatasource.spring.entity.Student;
import com.java.multipledatasource.spring.vo.Person;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

/**
 * @author hu
 * @version 1.0
 * @date 2021/1/25 0025 上午 9:16
 * @description
 */
@Component
@Configuration  //加了Configuration 生成的student 是同一个对象
public class Config {

    @Bean
    public Student student(){
        return new Student();
    }

    @Bean
    public Person person(){
        // person 方法在执行 student()方法的时候 会走代理逻辑，
        // 会把方法名字作为参数调用 getBean("student")
        Student student = student();
        return new Person();
    }
}
